﻿namespace AutoRevit.Entry.Command;

/// <summary>
/// 鉴权验证外部命令
/// </summary>
public abstract class AuthenticationCommand : AutoCommand, IInterceptorExtend
{
    /// <summary>
    /// 实例化
    /// </summary>
    public AuthenticationCommand()
    {
        Interceptors.Add(new LiteHandlerInterceptor(rd => new HandlerResult(Result.Cancelled, Pass(rd))));
    }

    /// <inheritdoc/>
    public List<IExternalCommandInterceptor> Interceptors { get; set; } = [];
    
    /// <inheritdoc/>
    public bool CanInterceptorExecute(IRevitData revitData)
    {
        return true;
    }

    /// <summary>
    /// 是否验证通过
    /// </summary>
    /// <param name="revitData"></param>
    /// <returns></returns>
    protected abstract bool Pass(IRevitData revitData);
}
